{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "81cca047",
   "metadata": {},
   "source": [
    "------------------------\n",
    "\n",
    "本周学习内容：莫金婵\n",
    "学习时间： 2021-11-04\n",
    "week05\n",
    "[参考文档] (https://python.org/doc)\n",
    "\n",
    "[许老师博客](https://www.cnblogs.com/xuzhichao)\n",
    "\n",
    "\n",
    "\n",
    "# 本周学习内容\n",
    "\n",
    "# 1.啤酒歌谣\n",
    "\n",
    "# 2.用户输入\n",
    "3.\n",
    "4.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c9d6a80",
   "metadata": {},
   "source": [
    "# 1.啤酒歌谣（p43自己写 p44课本解读）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "250882b0",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character in identifier (<ipython-input-4-fd73cdf8d640>, line 5)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-4-fd73cdf8d640>\"\u001b[1;36m, line \u001b[1;32m5\u001b[0m\n\u001b[1;33m    print(beer_num,(\"瓶\")，word)\u001b[0m\n\u001b[1;37m                            ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character in identifier\n"
     ]
    }
   ],
   "source": [
    "word = \"青岛s\"\n",
    "# 循环 ， for 一般和range使用， range 决定循环次数\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"啤酒柜中\")\n",
    "    print(beer_num,(\"瓶\")，word)\n",
    "    print(\"一次可以拿一瓶~\")\n",
    "    print(\"pass it around~\")\n",
    "    \n",
    "    if beer_num == 1:\n",
    "        print(\"没有啤酒可以拿走了，今日已卖完\")\n",
    "    else:\n",
    "        new num = beer_num - 1\n",
    "        if new_num ==1:\n",
    "            word = \"青岛\"\n",
    "        print(new_num,word,\"在酒柜中\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "adde759c",
   "metadata": {},
   "source": [
    "# 2. 用户输入（input）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "fab8fe99",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 变量赋值（我们决定变量的数据结构和内容）\n",
    "username = \"zhichao\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "fc9a0fbb",
   "metadata": {},
   "outputs": [],
   "source": [
    "username = \"Jack\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "79ba840c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Jack'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0596eaff",
   "metadata": {},
   "source": [
    "'Jack'\n",
    "input ： 变量赋值是 --> 用户数据\n",
    "input的数据类型是 --> str(字符串)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "5f77daba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入你的账号：12345\n"
     ]
    }
   ],
   "source": [
    "# 1. input ： 变量赋值的内容是 --> 用户数据（用户决定数据内容）\n",
    "# 2. input的数据类型是 --> str(字符串)\n",
    "username = input(\"请输入你的账号：\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "9a918a99",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12345\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(username)\n",
    "print(type(username))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "7608f710",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'12345'"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b16fe16",
   "metadata": {},
   "source": [
    "# 2.1 input 实践：用户登录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "7577c318",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyboardInterrupt",
     "evalue": "Interrupted by user",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-42-c7999226e66c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;31m#用户登录：\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0musername\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"请输入你的账号：\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      8\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0musername_data\u001b[0m \u001b[1;33m==\u001b[0m\u001b[0musername\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m     \u001b[1;31m# 账号存在\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\PY\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m    858\u001b[0m                 \u001b[1;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    859\u001b[0m             )\n\u001b[1;32m--> 860\u001b[1;33m         return self._input_request(str(prompt),\n\u001b[0m\u001b[0;32m    861\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    862\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\PY\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m    902\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    903\u001b[0m                 \u001b[1;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 904\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Interrupted by user\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    905\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    906\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Invalid Message:\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
     ]
    }
   ],
   "source": [
    "# 首先 数据库信息有账号和密码\n",
    "username_data = \"alex\"\n",
    "password_data = \"123456\"\n",
    "\n",
    "#用户登录：\n",
    "\n",
    "username = input(\"请输入你的账号：\")\n",
    "if username_data ==username:\n",
    "    # 账号存在\n",
    "    password = input(\"请输入你的密码：\")\n",
    "    if password_data == password:\n",
    "        print(\"欢迎\",username,\"使用~\")\n",
    "        break\n",
    "    #账号正确 密码不正确\n",
    "    else:\n",
    "        print(\"你输入的密码不正确！ 请检查~\")\n",
    "else:\n",
    "    print(\"你输入的账号不存在，请检查~\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "b7ccdb0b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入你的账号：alex\n",
      "请输入你的密码：5\n",
      "你的账号不存在或密码不正确~请重新输入，您还有 2 次机会使用,否则请5分钟后再试\n",
      "请输入你的账号：alex\n",
      "请输入你的密码：5\n",
      "你的账号不存在或密码不正确~请重新输入，您还有 1 次机会使用,否则请5分钟后再试\n",
      "请输入你的账号：alex\n",
      "请输入你的密码：6\n",
      "请5s后在尝试\n",
      "请输入你的账号：alex\n",
      "请输入你的密码：5\n",
      "你的账号不存在或密码不正确~请重新输入，您还有 2 次机会使用,否则请5分钟后再试\n",
      "请输入你的账号：alex\n",
      "请输入你的密码：123456\n",
      "欢迎 alex 使用~\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "username_data = \"alex\"\n",
    "password_data = \"123456\"\n",
    "\n",
    "count = 3\n",
    "while True:\n",
    "    count -= 1 # 等价于count = - 1\n",
    "    username = input(\"请输入你的账号：\")\n",
    "    password = input(\"请输入你的密码：\")\n",
    "    \n",
    "    if username_data == username:\n",
    "        if password_data == password:\n",
    "            print(\"欢迎\",username,\"使用~\")\n",
    "            break\n",
    "        else:\n",
    "            if count == 0:\n",
    "                print(\"请5s后在尝试\")\n",
    "                time.sleep(5)\n",
    "                count = 3\n",
    "            else:\n",
    "                #占位符：会改变的值（1.按照一定规律改变的值  2. 用户输入的值）\n",
    "                  print(\"你的账号不存在或密码不正确~请重新输入，您还有\",count,\"次机会使用,否则请5s后再试\")\n",
    "else:\n",
    "    if count == 0:\n",
    "        print(\"5s后再来尝试\")\n",
    "        time.sleep(5)\n",
    "        count = 3\n",
    "    else:\n",
    "        print(\"你的账号不存在或密码不正确~,请重新输入\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28b883ae",
   "metadata": {},
   "source": [
    "## 2.2 占位符和<font style =\"color:red\">字符串格式化</font>\n",
    "\n",
    "> 1. 实践 4.用户输入[%s格式化打印用户信息]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a657de2f",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyboardInterrupt",
     "evalue": "Interrupted by user",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-6a26cf3afae4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"name:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"age:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mjob\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"job:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[0msalary\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"salary:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\PY\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m    858\u001b[0m                 \u001b[1;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    859\u001b[0m             )\n\u001b[1;32m--> 860\u001b[1;33m         return self._input_request(str(prompt),\n\u001b[0m\u001b[0;32m    861\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    862\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\PY\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m    902\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    903\u001b[0m                 \u001b[1;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 904\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Interrupted by user\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    905\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    906\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Invalid Message:\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%s\n",
    "Job:%s\n",
    "Salary:%s\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0db1c785",
   "metadata": {},
   "source": [
    "请同学们实践 4、用户输入 .format()打印用户信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "acf00fe4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "09136588",
   "metadata": {},
   "source": [
    "# 2.while true循环\n",
    "1.while true： 无限循环,当我们不确定循环次数时，一定要想到while True\n",
    "2.break 跳出循环：当符合某条件时，结束循环\n",
    "3.while True 也可以指定循环次数~，只不过循环次数也是用条件来决定的，条件称：计数器 count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "9d031a2e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿，我是沙~循循环环到天涯 1\n",
      "你是风儿，我是沙~循循环环到天涯 2\n",
      "你是风儿，我是沙~循循环环到天涯 3\n",
      "你是风儿，我是沙~循循环环到天涯 4\n",
      "你是风儿，我是沙~循循环环到天涯 5\n",
      "你是风儿，我是沙~循循环环到天涯 6\n",
      "你是风儿，我是沙~循循环环到天涯 7\n",
      "你是风儿，我是沙~循循环环到天涯 8\n",
      "你是风儿，我是沙~循循环环到天涯 9\n",
      "你是风儿，我是沙~循循环环到天涯 10\n",
      "你是风儿，我是沙~循循环环到天涯 11\n",
      "你是风儿，我是沙~循循环环到天涯 12\n",
      "你是风儿，我是沙~循循环环到天涯 13\n",
      "你是风儿，我是沙~循循环环到天涯 14\n",
      "你是风儿，我是沙~循循环环到天涯 15\n",
      "你是风儿，我是沙~循循环环到天涯 16\n",
      "你是风儿，我是沙~循循环环到天涯 17\n",
      "你是风儿，我是沙~循循环环到天涯 18\n",
      "你是风儿，我是沙~循循环环到天涯 19\n",
      "你是风儿，我是沙~循循环环到天涯 20\n",
      "你是风儿，我是沙~循循环环到天涯 21\n",
      "你是风儿，我是沙~循循环环到天涯 22\n",
      "你是风儿，我是沙~循循环环到天涯 23\n",
      "你是风儿，我是沙~循循环环到天涯 24\n",
      "你是风儿，我是沙~循循环环到天涯 25\n",
      "你是风儿，我是沙~循循环环到天涯 26\n",
      "你是风儿，我是沙~循循环环到天涯 27\n",
      "你是风儿，我是沙~循循环环到天涯 28\n",
      "你是风儿，我是沙~循循环环到天涯 29\n",
      "你是风儿，我是沙~循循环环到天涯 30\n",
      "你是风儿，我是沙~循循环环到天涯 31\n",
      "你是风儿，我是沙~循循环环到天涯 32\n",
      "你是风儿，我是沙~循循环环到天涯 33\n",
      "你是风儿，我是沙~循循环环到天涯 34\n",
      "你是风儿，我是沙~循循环环到天涯 35\n",
      "你是风儿，我是沙~循循环环到天涯 36\n",
      "你是风儿，我是沙~循循环环到天涯 37\n",
      "你是风儿，我是沙~循循环环到天涯 38\n",
      "你是风儿，我是沙~循循环环到天涯 39\n",
      "你是风儿，我是沙~循循环环到天涯 40\n",
      "你是风儿，我是沙~循循环环到天涯 41\n",
      "你是风儿，我是沙~循循环环到天涯 42\n",
      "你是风儿，我是沙~循循环环到天涯 43\n",
      "你是风儿，我是沙~循循环环到天涯 44\n",
      "你是风儿，我是沙~循循环环到天涯 45\n",
      "你是风儿，我是沙~循循环环到天涯 46\n",
      "你是风儿，我是沙~循循环环到天涯 47\n",
      "你是风儿，我是沙~循循环环到天涯 48\n",
      "你是风儿，我是沙~循循环环到天涯 49\n",
      "你是风儿，我是沙~循循环环到天涯 50\n"
     ]
    }
   ],
   "source": [
    "count = 0\n",
    "while True:\n",
    "    count = count + 1\n",
    "    print(\"你是风儿，我是沙~循循环环到天涯\",count)\n",
    "    if count == 50:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38ad7f2e",
   "metadata": {},
   "source": [
    "# 列表的引入\n",
    "1. 什么是列表\n",
    "2. 列表的形式：[value1,value2,...]\n",
    "3. 列表也是 序列 数据类型\n",
    "4. 序列是有顺序的（即可以用索引 index 取值）\n",
    "5. 序列可以 切片 ,切片完的结果仍是一个 列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b044b81f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 4, 9, 16, 25]\n",
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "squares = [1, 4, 9, 16, 25]\n",
    "print(squares)\n",
    "print(type(squares))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cb9a2945",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Alex'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考： 用户账号数据不止一个，那么想存储怎么办？\n",
    "username_database = \"Alex,zhichao,xiaoming,Jack\"\n",
    "username_database[:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "29ef5fe0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Alex'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list = [\"Alex\",\"zhichao\",\"xiaoming\",\"Jack\"]\n",
    "username_database_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7641d6e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'zhichao'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8941c039",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Alex', 'zhichao']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d988adcf",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
